// Copyright (C) 2010 Razvan Constantin <razvan.constantin@rconst.net>
//
// This file is part of FileBow.
//
// FileBow is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// FileBow is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FileBow.  If not, see <http://www.gnu.org/licenses/>.

#ifndef FILEBOW_LOGIC_HISTORY_H__
#define FILEBOW_LOGIC_HISTORY_H__

#include <map>
#include <queue>
#include <string>

#include "logic/path-tree.h"

namespace filebow {
class FileScorer;

/**
 * Keeps track of files opened and/or activated. Provides score for them.
 */
class History {

  /**
   * Initializes a new empty history instance.
   */
  public: History();

  /**
   * Destructor.
   */
  public: ~History();

  /**
   * Active file.
   */
  public: const std::string& active() const;

  /**
   * Tracks opening of a file.
   */
  public: void TrackOpen(const std::string& file);

  /**
   * Tracks activation of a file.
   */
  public: void TrackActivate(const std::string& file);

  /**
   * Tracks closing of a file.
   */
  public: void TrackClose(const std::string& file);

  // Gets the history scorer over the specified tree.
  public: FileScorer* GetScorer(PathTree* tree) const;

  /**
   * List of files open events in order.
   */
  private: std::queue<std::string> mHistory;

  /**
   * Frequency of opening for each file.
   */
  private: std::map<std::string, int> mFrequency;
};

} // namespace filebow

#endif // FILEBOW_LOGIC_HISTORY_H__

